package com.recon.template;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author hugh.zhou
 * @version V1.0
 * @Title: Swagger设置类
 * @Package
 * @date 2017年12月19日 上午9:45:55
 */
@Configuration
@ComponentScan(basePackages = {"com.recon.*.controller"})
@EnableSwagger2
public class Swagger2 {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .paths(Predicates.or(
                        //这里添加你需要展示的接口
                        PathSelectors.ant("/template/**")
//                        ,PathSelectors.ant("/apis/**")
//                        ,PathSelectors.ant("/check/**")
                        )
                )
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("联合睿康--睿平台--微服务API管理平台")
                .description("说明RESTful Dict")
//                .contact("recon@reconig.com")
                .contact(new Contact("recon@reconig.com",null,null))
                .version("1.0")
                .build();
    }
}
